package ar.edu.itba.ontologias.TPONTO;

import org.openrdf.repository.RepositoryException;

import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.model.Property;
import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.sparql.vocabulary.FOAF;
import com.hp.hpl.jena.vocabulary.VCARD;

public class Start {

	/**
	 * @param args
	 * @throws RepositoryException 
	 */
	public static void main(String[] args) {
		//ACA VA LA URL
		//String sesameServer = "http://localhost:8080/openrdf-sesame";
		//ACA VA EL ID DEL REPOSITORY
		//String repositoryID = "TPONTO";

		//Repository myRepository = new HTTPRepository(sesameServer, repositoryID);
		//try {
			
		
		/*
		<rdf:Description rdf:ID="pid012">
			<rdf:type rdf:resource="#Person"/>
			<foaf:name>Jorge Lopez</foaf:name>
			<birthDate>1948-05-25</birthDate>
			<deathDate>2007-03-15</deathDate>
			<country>Argentina</country>
			<foaf:img>http://www.cinenacional.com/foto.jpg</foaf:img>
			<actedOn rdf:Resource="mid018"/>
			<actedOn rdf:Resource="mid023"/>
		</rdf:Description>
		 * 
		 * 
		 * <rdf:Property rdf:ID="actedOn">
				<rdfs:subPropertyOf rdf:resource="foaf:pastProject"/>
			</rdf:Property>
		 * 
		 */
		
			Person p = new Person("jorge-lopez", "Jorge", "1990-03-19", null, "argentina", null, null);
			
			//myRepository.initialize();
			
			//String NS = "http://xmlns.com/foaf/0.1/Person/";
			
			Model m = ModelFactory.createDefaultModel();
			
			String NS = "http://www.example.org/Person";
			
			//Resource r = m.createResource(NS + p.getNode());
			Resource r = m.createResource(NS + "#" + p.getPath());
			
			if(p.getName()!=null)
				r.addProperty(FOAF.name, p.getName());
			if(p.getCountry()!=null)	
				r.addProperty(VCARD.Country, p.getCountry());
			if(p.getBirthDate()!=null)
				r.addProperty(FOAF.birthday, p.getBirthDate().toString());
			if(p.getImageUrl()!=null)
				r.addProperty(FOAF.img, p.getImageUrl());
			
			Property algo = m.createProperty(NS, "length");
			r.addProperty(algo, "sadasdad");
			//if(p.getDeathDate()!=null){
			//	Property pDeath = m.createProperty(NS + "death");
			//	r.addProperty(pDeath, p.getDeathDate().toString());
			//}
			/*if(p.getPast().size()>0){
				Map<String, List<String>> past = p.getPast();
				for(Entry<String, List<String>> entry : past.entrySet()){
					
				}
				r.addProperty(FOAF.pastProject, )
			}*/
			
			//Property pPastProject = m.createProperty(NS + "pastProject");
			
				
			
			m.write(System.out);
			System.exit(0);
			
			/*
			ValueFactory f = myRepository.getValueFactory();
			URI person = f.createURI("http://xmlns.com/foaf/0.1/Person#");
			
			URI name = f.createURI(person.getNamespace(), p.getName());
			URI country = f.createURI(person.getNamespace(), p.getCountry());
			RepositoryConnection con = myRepository.getConnection();
			try {
				con.add(name, RDFS.CLASS, person);
				con.add(country, RDF.PROPERTY, name);
			}
			finally {
				con.close();
			}

		} catch (RepositoryException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		System.exit(0);
		*/
	}

}
